# Installation Steps Based on:
# http://unix.stackexchange.com/questions/115586/centos-how-to-update-ant-version-to-1-8-x-and-higher

Download and Extract Ant 1.9.5 Binaries:
  archive.extracted:
    - name: /opt/
    - source: http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.5-bin.tar.gz
    - source_hash: http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.5-bin.tar.gz.sha1
    - tar_options: v
    - archive_format: tar
    - if_missing: /opt/apache-ant-1.9.5/
    
Make A Symlink for Ant 1.9.5 Home at /opt/ant:
  file.symlink:
    - name: /opt/ant
    - target: /opt/apache-ant-1.9.5
        
Make A Symlink for Ant 1.9.5 Binary at /usr/bin/ant:
  file.symlink:
    - name: /usr/bin/ant
    - target: /opt/ant/bin/ant
    - force: True

# There are two set environment state here, for different purpose

# This one is for permanent ENV variable
Add new ANT_HOME to /etc/environment:
  file.append:
    - name: /etc/environment
    - text: ANT_HOME=/opt/ant

# /etc/environment only works when user re-login. It wont work on current process
# This one is to make sure the current process has the env too
Set ENV for CURRENT:
  environ.setenv:
    - name: ANT_HOME
    - value: /opt/ant
    - update_minion: True
